<template>
	<view class="page" :style="themeColor">

		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
			<view class='flex flex-direction flex-wrap align-center flex-sub register_fd0_0'>
				<image class='register_fd0_0_c0' mode="aspectFill" :src='STATIC_URL+"2.png"'></image>
			</view>
			<view class='flex flex-wrap align-center register_fd0_1'>
				<image class='register_fd0_1_c0' mode="aspectFill" :src='STATIC_URL+"3.png"'></image>
				<input class='register_fd0_1_c1' type="number" placeholder="请输入手机号" confirm-type="done"
					:maxlength="11" placeholder-style="color:rgba(153, 153, 153, 1);font-size:25rpx" v-model="mobile" />
			</view>
			<view class='flex flex-wrap align-center register_fd0_2'>
				<image class='register_fd0_1_c0' mode="aspectFill" :src='STATIC_URL+"5.png"'></image>
				<input class='flex-sub register_fd0_1_c1' type="number" placeholder="请输入验证码" confirm-type="done"
					:maxlength="4" placeholder-style="color:rgba(153, 153, 153, 1);font-size:25rpx" v-model="code" />
				<benben-send-verification-code class='flex  register_fd0_2_c2' after-text='后重新获取' before-text='获取验证码'
					type='1' :phone="mobile"></benben-send-verification-code>
			</view>
			<view class='flex flex-wrap align-center register_fd0_2'>
				<image class='register_fd0_1_c0' mode="aspectFill" :src='STATIC_URL+"4.png"'></image>
				<benben-flex-password-diy v-model="password"
					class-name="flex align-center flex-sub flex register_fd0_3_c1" :placeholder="'请输入密码(6~12位字母+数字)'"
					:maxlength="12" :default-type='true'
					placeholder-style="color:rgba(153, 153, 153, 1);font-size:25rpx">
					<template #show>
						<text class='fu-iconfont2  register_fd0_3_c1_icon1' data-type="show">&#xE837;</text>
					</template>
					<template #hide>
						<text class='fu-iconfont2  register_fd0_3_c1_icon2' data-type="hide">&#xEBCC;</text>
					</template>
				</benben-flex-password-diy>
			</view>
			<view class='flex flex-wrap align-center register_fd0_2'>
				<image class='register_fd0_1_c0' mode="aspectFill" :src='STATIC_URL+"4.png"'></image>
				<benben-flex-password-diy v-model="confirmPassword"
					class-name="flex align-center flex-sub flex register_fd0_3_c1" :placeholder="'请再次输入密码(6~12位字母+数字)'"
					:maxlength="12" :default-type='true'
					placeholder-style="color:rgba(153, 153, 153, 1);font-size:25rpx">
					<template #show>
						<text class='fu-iconfont2  register_fd0_3_c1_icon1' data-type="show">&#xE837;</text>
					</template>
					<template #hide>
						<text class='fu-iconfont2  register_fd0_3_c1_icon2' data-type="hide">&#xEBCC;</text>
					</template>
				</benben-flex-password-diy>
			</view>
			<view class='flex flex-wrap align-center register_fd0_1' style="margin-top: 40rpx;">
				<image class='register_fd0_1_c0' mode="aspectFill" :src='STATIC_URL+"6.png"'></image>
				<input class='register_fd0_1_c1' type="text" placeholder="请输入机构代码" confirm-type="done"
					:maxlength="-1" placeholder-style="color:rgba(153, 153, 153, 1);font-size:25rpx" v-model="org_code" />
			</view>
			<view class='flex align-center justify-center register_fd0_4'>
				<button class='register_fd0_4_c0' @tap.stop="goRegisterFunc()">注册</button>
			</view>
			<view class='flex flex-wrap align-center justify-center register_fd0_5'>
				<text class='register_fd0_5_c0'>已有账号，前去</text>
				<text class='register_fd0_5_c1' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/tabBar/login/login`">登录</text>
			</view>
			<view class='flex flex-wrap align-center justify-center register_fd0_6'>
				<benben-flex-switch-new class-name='flex flex register_fd0_6_c0' v-model="check" :disabled='false'>
					<template v-slot:checked>

						<view class='flex flex position-relative align-center'>
							<image class='register_checkfd0_6_c0_c0_c0' mode="aspectFit" :src='STATIC_URL+"10.png"'>
							</image>
						</view>

					</template>
					<template v-slot:unchecked>

						<view class='flex flex position-relative justify-end align-center'>
							<image class='register_noCheckfd0_6_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"11.png"'>
							</image>
						</view>

					</template>
				</benben-flex-switch-new>
				<text class='register_fd0_6_c1'>已阅读并同意</text>
				<text class='register_fd0_6_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dlzc/agreement/agreement?aid=1`">《用户注册协议》</text>
				<text class='register_fd0_6_c1'>与</text>
				<text class='register_fd0_6_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dlzc/agreement/agreement?aid=2`">《隐私政策》</text>
			</view>
		</view>




	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"code": "",
				"mobile": "",
				"password": "",
				"confirmPassword": "",
				"org_code": "",
				"userInfo": {},
				"check": false,
				"is_click": false,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//注册
			async goRegisterFunc() {
				if (this.is_click) return;
				if (!validate(this.mobile, 'require')) {
					this.$message.info('手机号不能为空');
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info('验证码不能为空');
					return false;
				}
				if (!validate(this.password, 'require')) {
					this.$message.info('密码不能为空');
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info('请输入6-12位字母+数字密码');
					return false;
				}
				if (!validate(this.confirmPassword, 'require')) {
					this.$message.info('确认密码不能为空');
					return false;
				}
				if (!validate(this.confirmPassword, 'password')) {
					this.$message.info('请输入6-12位字母+数字确认密码');
					return false;
				}
				if (this.password != this.confirmPassword) {
					this.$message.info('两次密码不一致');
					return false;
				}
				if (!this.org_code) {
					this.$message.info('请输入机构代码');
					return;
				}
				if (this.check === false) {
					this.$message.info('请阅读并同意用户注册协议和隐私政策');
					return false;
				}
				uni.showLoading();
				this.is_click = true;
				let datauserInfo = await this.$api.post(global.apiUrls.post5cad9f63e4f94, {
					code: this.code,
					mobile: this.mobile,
					password: this.password,
					org_code: this.org_code,
					type: 1
				});
				if (datauserInfo.data.code != 1) {
					uni.hideLoading();
					this.is_click = false;
					this.$message.info(datauserInfo.data.msg);
					return
				}
				let infouserInfo = datauserInfo.data;
				this.userInfo = infouserInfo.data.userinfo
				this.$store.commit('saveToken', this.userInfo.user_token)
				this.$store.commit('updateUserInfo', this.userInfo)
				uni.hideLoading();
				this.$message.info(datauserInfo.data.msg);
				setTimeout(() => {
					this.is_click = false;
					uni.navigateTo({
						url: '/pages/dlzc/next/next'
					})
				}, 800)
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #FFFFFF;
		background: url(/static/images/1.png) no-repeat;
		background-size: 100% auto !important;
	}

	.register_fd0_6_c2 {
		color: #4087FD;
		font-size: 18rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.register_fd0_6_c1 {
		color: rgba(153, 153, 153, 1);
		font-size: 18rpx;
		font-weight: 400;
		line-height: 33rpx;
	}

	.register_noCheckfd0_6_c0_c1_c0 {
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		width: 24rpx;
		height: 24rpx;
	}

	.register_checkfd0_6_c0_c0_c0 {
		width: 24rpx;
		height: 24rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	::v-deep .register_fd0_6_c0 {
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.register_fd0_6 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		width: 100%;
		position: fixed;
		left: 0rpx;
		bottom: calc(60rpx + var(--window-bottom));
	}

	.register_fd0_5_c1 {
		font-size: 25rpx;
		font-weight: 500;
		color: #4087FD;
		line-height: 40rpx;
	}

	.register_fd0_5_c0 {
		font-size: 25rpx;
		font-weight: 500;
		color: rgba(51, 51, 51, 1);
		line-height: 40rpx;
	}

	.register_fd0_5 {
		line-height: 40rpx;
		margin: 36rpx 0rpx 0rpx 0rpx;
	}

	.register_fd0_4_c0 {
		background: #4087FD;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 25rpx;
		color: #fff;
		height: 68rpx;
		line-height: 68rpx;
		font-weight: 500;
		width: 625rpx;
	}

	.register_fd0_4 {
		margin: 98rpx 0rpx 0rpx 0rpx;
	}

	.register_fd0_3_c1_icon2 {
		text-align: center;
		font-size: 44rpx;
	}

	.register_fd0_3_c1_icon1 {
		text-align: center;
		font-size: 36rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	::v-deep .register_fd0_3_c1 {
		font-size: 28rpx;
		color: #333;
		font-weight: 400;
		width: 100%;
		// width: 494rpx;
		// flex: 1;
	}

	.register_fd0_2_c2 {
		font-size: 20rpx;
		font-weight: 400;
		color: #333333;
		line-height: 40rpx;
	}

	.register_fd0_2 {
		background: #F8F8F8;
		padding: 20rpx 40rpx 20rpx 40rpx;
		margin: 40rpx 63rpx 0rpx 63rpx;
		border-radius: 38rpx;
	}

	.register_fd0_1_c1 {
		line-height: 45rpx;
		font-size: 25rpx;
		font-weight: 400;
		color: #333;
		width: calc(100% - 50rpx);
	}

	.register_fd0_1_c0 {
		width: 28rpx;
		height: 28rpx;
		margin: 0rpx 22rpx 0rpx 0rpx;
	}

	.register_fd0_1 {
		background: #F8F8F8;
		padding: 20rpx 40rpx 20rpx 40rpx;
		margin: 0rpx 63rpx 0rpx 63rpx;
		border-radius: 38rpx;
	}

	.register_fd0_0_c0 {
		width: 150rpx;
		height: 150rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.register_fd0_0 {
		padding: 125rpx 0rpx 75rpx 0rpx;
		
	}
</style>